from typing import Optional, Dict

from pydantic import Field
from typing_extensions import Annotated

from owl_common.base.model import AuditEntity, VoAccess


class ChatFileMessage(AuditEntity):
    id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    chat_id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    message_id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    name: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]

    path: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]

    suffix: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]


class Agent(AuditEntity):
    id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    name: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]

    type: Annotated[
        str,
        Field(default='single', vo=VoAccess(query=True))
    ]

    config: Annotated[
        dict,
        Field(default=None, vo=VoAccess(query=True))
    ]


class Chat(AuditEntity):
    id: Annotated[
        Optional[int],
        Field(default=None, vo=VoAccess(query=True))
    ]

    name: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]

    agent_id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]


class ChatMessage(AuditEntity):
    """
    聊天消息实体类
    """
    id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    chat_id: Annotated[
        int,
        Field(default=None, vo=VoAccess(query=True))
    ]

    role: Annotated[
        str,
        Field(default=None, vo=VoAccess(query=True))
    ]

    content: Annotated[
        str | Dict,
        Field(default=None, vo=VoAccess(query=True))
    ]

    files: Annotated[
        Optional[list[int]],
        Field(default=None, vo=VoAccess(query=True))
    ]
